package com.vfa.test;

import java.util.ArrayList;

import com.vfa.vocaburay.R;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AnswerInsertAdapter extends BaseAdapter{

	
	 private LayoutInflater mInflater;
	    private ArrayList<String> data = new ArrayList<String>();
	     
	    public AnswerInsertAdapter(Context context) { 
	        data.add("Answer 1:");
	        mInflater = LayoutInflater.from(context);
	    }
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int item) {
		// TODO Auto-generated method stub
		//return item;
		return data.get(item);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
        
        if (convertView == null) {
            convertView    = mInflater.inflate(R.layout.item_insertedquestion, null);
             
            holder         = new ViewHolder();
             
            holder.mTitleText    = (TextView) convertView.findViewById(R.id.textView_answeritemnum);
             
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.mTitleText.setText(data.get(position));
         
        return convertView;
	}
	
	static class ViewHolder {
        TextView mTitleText;
    }
    public void addTail() {
        //Add 1 item vào đuôi
    	data.add("Answer "+(data.size()+1)+":");
    	Log.i("data add", "addddd");
        notifyDataSetChanged();
    }
    
    public void minusTail() {
        //Add 1 item vào đuôi
    	//data.add("Answer "+(data.size()+1)+":");
    	Log.i("data minus", "minus");
    	if(data.size()!=0)
    	{
    		data.remove((data.size()-1));
    	}
    	
        notifyDataSetChanged();
    }

}
